#!/bin/bash
vip="10.2.20.251"
netmask="255.255.255.0"
iface="eth0:0"
rs1="10.2.20.211"
rs2="10.2.20.212"
. /etc/rc.d/init.d/functions
start(){
	echo "Start LVS"
	echo "1" > /proc/sys/net/ipv4/ip_forward
	/usr/sbin/ifconfig $iface $vip netmask $netmask up
	/usr/sbin/route add -host $vip dev $iface
	/usr/sbin/ipvsadm -C
	/usr/sbin/ipvsadm -A -t $vip:80 -s wrr
	/usr/sbin/ipvsadm -a -t $vip:80 -r $rs1:80 -g -w 1
	/usr/sbin/ipvsadm -a -t $vip:80 -r $rs2:80 -g -w 2
}

stop(){
	echo "0" > /proc/sys/net/ipv4/ip_forward
	/usr/sbin/ifconfig $iface down
	/usr/sbin/ipvsadmin -C
}
case $1 in
start)
	start
	;;
stop)
	;;
*)
	echo "Usage:$0[start|stop]"
	exit 1
esac

